import request from '@/router/axios'
const scope = 'server'

export const loginByUsername = (username, password, code, randomStr) => {
  const grant_type = 'password'

  return request({
    //url: '/auth/oauth/token',
    url: '/login',
    headers: {
      isToken:false
      //'Authorization': 'Basic Y2hjaXQtYWRtaW46Y2hjaXQtYWRtaW4='
    },
    method: 'post',
    params: { username, password, randomStr, code, grant_type, scope }
  })
}

// export const refreshToken = (refresh_token) => {
//   const grant_type = 'refresh_token'
//   return request({
//     url: '/auth/oauth/token',
//     headers: {
//       'isToken': false,
//       'Authorization': 'Basic Y2hjaXQtYWRtaW46Y2hjaXQtYWRtaW4',
//     },
//     method: 'post',
//     params: { refresh_token, grant_type, scope }
//   })
// }

// export const loginByMobile = (mobile, code) => {
//   const grant_type = 'mobile'
//   return request({
//     url: '/auth/mobile/token/sms',
//     headers: {
//       'Authorization': 'Basic Y2hjaXQtYWRtaW46Y2hjaXQtYWRtaW4'
//     },
//     method: 'post',
//     params: { mobile: 'SMS@' + mobile, code: code, grant_type }
//   })
// }

// export const loginBySocial = (state, code) => {
//   const grant_type = 'mobile'
//   return request({
//     url: '/auth/mobile/token/social',
//     headers: {
//       'Authorization': 'Basic Y2hjaXQtYWRtaW46Y2hjaXQtYWRtaW4'
//     },
//     method: 'post',
//     params: { mobile: state + '@' + code, grant_type }
//   })
// }


export const logout = () => {
  return request({
//    url: '/auth/oauth/removeToken',
//    method: 'get'
//   url: '/auth/token/logout',
   url: '/logout',
   method: 'delete'
  })
}
